{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-12T14:02:12.018077Z",
     "iopub.status.busy": "2022-05-12T14:02:12.018077Z",
     "iopub.status.idle": "2022-05-12T14:02:14.185806Z",
     "shell.execute_reply": "2022-05-12T14:02:14.184814Z",
     "shell.execute_reply.started": "2022-05-12T14:02:12.018077Z"
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "欢迎使用缠论数据计算工具；\n",
      "项目地址：https://github.com/yijixiuxin/chanlun-pro\n",
      "授权许可有效期：2099-01-01\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "在使用天勤量化之前，默认您已经知晓并同意以下免责条款，如果不同意请立即停止使用：https://www.shinnytech.com/blog/disclaimer/\n"
     ]
    }
   ],
   "source": [
    "from chanlun.backtesting import backtest\n",
    "from chanlun.backtesting.optimize import OptimizationSetting\n",
    "from chanlun.strategy.strategy_a_single_all_mmd import StrategyASingleAllMmd\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-12T14:02:14.187810Z",
     "iopub.status.busy": "2022-05-12T14:02:14.187810Z",
     "iopub.status.idle": "2022-05-12T14:02:14.217806Z",
     "shell.execute_reply": "2022-05-12T14:02:14.216803Z",
     "shell.execute_reply.started": "2022-05-12T14:02:14.187810Z"
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# 量化配置\n",
    "bt_config = {\n",
    "    # 策略结果保存的文件\n",
    "    'save_file': './data/bk/a_strategy_a_single_allmmd_signal.pkl',\n",
    "    # 设置策略对象\n",
    "    'strategy': StrategyASingleAllMmd(),\n",
    "    # 回测模式：signal 信号模式，固定金额开仓； trade 交易模式，按照实际金额开仓\n",
    "    'mode': 'trade',\n",
    "    # 市场配置，currency 数字货币  a 沪深  hk  港股  futures  期货\n",
    "    'market': 'a',\n",
    "    # 基准代码，用于获取回测的时间列表\n",
    "    'base_code': 'SH.000001',\n",
    "    # 回测的标的代码，符合条件股票并按市值排行前100股票\n",
    "    'codes': [\"SH.600519\", \"SH.601398\", \"SH.601939\", \"SH.601288\", \"SH.601857\", \"SH.600036\", \"SH.601988\", \"SH.601318\", \"SZ.002594\", \"SH.601628\", \"SZ.000858\", \"SH.601088\", \"SH.600028\", \"SH.600900\", \"SH.601658\", \"SH.601166\", \"SZ.000333\", \"SZ.300760\", \"SH.601012\", \"SH.601328\", \"SH.603288\", \"SZ.002415\", \"SH.601888\", \"SH.600809\", \"SH.688981\", \"SZ.000568\", \"SZ.000001\", \"SZ.300059\", \"SH.603259\", \"SH.600030\", \"SH.601899\", \"SZ.002714\", \"SH.601668\", \"SH.600309\", \"SH.600690\", \"SH.600887\", \"SZ.002352\", \"SZ.002304\", \"SH.601919\", \"SZ.002142\", \"SH.600000\", \"SH.601998\", \"SH.601633\", \"SZ.000002\", \"SH.601816\", \"SH.600585\", \"SZ.002475\", \"SH.600048\", \"SH.601319\", \"SZ.000651\", \"SH.601601\", \"SZ.300015\", \"SH.600104\", \"SH.601138\", \"SH.600276\", \"SH.600436\", \"SH.600438\", \"SZ.002812\", \"SH.601995\", \"SH.601390\", \"SH.600406\", \"SH.601800\", \"SH.600188\", \"SH.601818\", \"SH.601066\", \"SH.600905\", \"SH.601225\", \"SH.600016\", \"SZ.000792\", \"SZ.300122\", \"SH.600346\", \"SZ.002460\", \"SH.600018\", \"SH.603392\", \"SZ.000725\", \"SH.601766\", \"SZ.003816\", \"SZ.002493\", \"SH.600031\", \"SH.600019\", \"SH.601111\", \"SH.601985\", \"SZ.002459\", \"SH.603501\", \"SH.601211\", \"SH.601238\", \"SZ.002129\", \"SH.601898\", \"SZ.300014\", \"SZ.002371\", \"SZ.002241\", \"SH.601688\", \"SZ.000776\", \"SZ.300498\", \"SZ.002271\", \"SH.600600\", \"SH.600837\", \"SZ.001979\", \"SH.601669\", \"SH.601009\"],\n",
    "    # 回测的周期，这里设置里，在策略中才能取到对应周期的数据\n",
    "    'frequencys': ['d'],\n",
    "    # 回测开始的时间\n",
    "    'start_datetime': '2017-01-01 00:00:00',\n",
    "    # 回测的结束时间\n",
    "    'end_datetime': '2022-04-20 00:00:00',\n",
    "    # mode 为 trade 生效，初始账户资金\n",
    "    'init_balance': 1000000,\n",
    "    # mode 为 trade 生效，交易手续费率\n",
    "    'fee_rate': 0.0006,\n",
    "    # mode 为 trade 生效，最大持仓数量（分仓）\n",
    "    'max_pos': 10,\n",
    "    # 缠论计算的配置，详见缠论配置说明\n",
    "    'cl_config': {\n",
    "        'default': {\n",
    "            'fx_bh': 'fx_bh_yes', 'fx_qj': 'fx_qj_k',\n",
    "            'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'bi_qj': 'bi_qj_dd', 'bi_fx_cgd': 'bi_fx_cgd_no',\n",
    "            'xd_bzh': 'xd_bzh_no', 'zsd_bzh': 'zsd_bzh_no',\n",
    "            'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz',\n",
    "            'zs_wzgx': 'zs_wzgx_zggdd', 'xd_qj': 'xd_qj_dd', 'zsd_qj': 'zsd_qj_dd', 'zs_qj': 'zs_qj_ck'\n",
    "        },\n",
    "        # '5m': {\n",
    "        #     'fx_bh': 'fx_bh_yes', 'fx_qj': 'fx_qj_k',\n",
    "        #     'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'bi_qj': 'bi_qj_dd', 'bi_fx_cgd': 'bi_fx_cgd_no',\n",
    "        #     'xd_bzh': 'xd_bzh_no', 'zsd_bzh': 'zsd_bzh_no',\n",
    "        #     'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz',\n",
    "        #     'zs_wzgx': 'zs_wzgx_zggdd', 'xd_qj': 'xd_qj_dd', 'zsd_qj': 'zsd_qj_dd', 'zs_qj': 'zs_qj_dd'\n",
    "        # }\n",
    "    },\n",
    "}\n",
    "\n",
    "# 参数优化设置\n",
    "setting = OptimizationSetting()\n",
    "setting.add_cl_parameter('bi_type', ['bi_type_old', 'bi_type_new'])\n",
    "setting.add_cl_parameter('bi_bzh', ['bi_bzh_yes', 'bi_bzh_no'])\n",
    "setting.add_cl_parameter('zs_bi_type', ['zs_type_bz', 'zs_type_dn'])\n",
    "setting.add_cl_parameter('zs_xd_type', ['zs_type_bz', 'zs_type_dn'])\n",
    "\n",
    "\n",
    "BT = backtest.BackTest(bt_config)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-05-12T14:02:14.218806Z",
     "iopub.status.busy": "2022-05-12T14:02:14.218806Z",
     "iopub.status.idle": "2022-05-12T14:55:50.612848Z",
     "shell.execute_reply": "2022-05-12T14:55:50.611849Z",
     "shell.execute_reply.started": "2022-05-12T14:02:14.218806Z"
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "开始执行穷举算法优化\n",
      "参数优化空间：16\n",
      "穷举算法优化完成，耗时3192秒\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652365769.0102267.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：2,437,642.63 总手续费：20,941.03\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：143.76% 年化收益率：26.81%\n",
      "最大回撤：-368,374.93 百分比最大回撤：-26.71% 最长回撤天数：33\n",
      "日均收益率：0.07% 收益标准差：1.22% Sharpe Ratio: 0.86 收益回撤比：5.38 \n",
      "+--------------+------+------+--------+------------+-----------+------------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利    |    亏损   |   净利润   | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+------------+-----------+------------+----------+----------+----------+--------+\n",
      "|   一类买点   |  3   |  1   | 75.0%  |  82517.11  |  13415.78 |  69101.34  |  16.26   | 27505.7  | 13415.78 | 2.0503 |\n",
      "|   二类买点   |  2   |  4   | 33.33% |  88777.05  |  31772.44 |  57004.61  |  35.79   | 44388.52 | 7943.11  | 5.5883 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  37  |  49  | 43.02% | 1572333.63 | 453329.28 | 1119004.35 |  28.83   | 42495.5  | 9251.62  | 4.5933 |\n",
      "|  类三类买点  |  15  |  19  | 44.12% | 248051.04  | 145624.28 | 102426.76  |  58.71   | 16536.74 | 7664.44  | 2.1576 |\n",
      "| 下跌盘整背驰 |  4   |  6   | 40.0%  | 150195.09  |  39525.98 | 110669.11  |  26.32   | 37548.77 | 6587.66  | 5.6999 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0      |     0     |     0      |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+------------+-----------+------------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652367274.7952995.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：2,229,629.08 总手续费：22,714.68\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：122.96% 年化收益率：22.93%\n",
      "最大回撤：-618,818.05 百分比最大回撤：-24.17% 最长回撤天数：64\n",
      "日均收益率：0.06% 收益标准差：1.18% Sharpe Ratio: 0.79 收益回撤比：5.09 \n",
      "+--------------+------+------+--------+------------+-----------+-----------+----------+-----------+----------+---------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利    |    亏损   |   净利润  | 回吐比例 |  平均盈利 | 平均亏损 |  盈亏比 |\n",
      "+--------------+------+------+--------+------------+-----------+-----------+----------+-----------+----------+---------+\n",
      "|   一类买点   |  3   |  3   | 50.0%  | 145671.89  |  27364.95 | 118306.94 |  18.79   |  48557.3  | 9121.65  |  5.3233 |\n",
      "|   二类买点   |  2   |  11  | 15.38% |  87965.11  |  90207.81 |  -2242.71 |  102.55  |  43982.55 | 8200.71  |  5.3633 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类买点   |  32  |  53  | 37.65% | 840356.13  | 586463.94 |  253892.2 |  69.79   |  26261.13 | 11065.36 |  2.3733 |\n",
      "|  类三类买点  |  12  |  13  | 48.0%  | 133178.69  |  91304.52 |  41874.17 |  68.56   |  11098.22 | 7023.42  |  1.5802 |\n",
      "| 下跌盘整背驰 |  6   |  20  | 23.08% | 1060748.23 |  220344.2 | 840404.03 |  20.77   | 176791.37 | 11017.21 | 16.0468 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "+--------------+------+------+--------+------------+-----------+-----------+----------+-----------+----------+---------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652365754.5777833.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：2,163,683.50 总手续费：20,710.62\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：116.37% 年化收益率：21.70%\n",
      "最大回撤：-401,629.19 百分比最大回撤：-29.17% 最长回撤天数：570\n",
      "日均收益率：0.06% 收益标准差：1.09% Sharpe Ratio: 0.82 收益回撤比：3.99 \n",
      "+--------------+------+------+--------+------------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利    |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+------------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  2   |  1   | 66.67% |  62065.52  |  10480.15 |  51585.36 |  16.89   | 31032.76 | 10480.15 | 2.9611 |\n",
      "|   二类买点   |  1   |  3   | 25.0%  |  67240.18  |  24700.12 |  42540.05 |  36.73   | 67240.18 | 8233.37  | 8.1668 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  31  |  51  | 37.8%  | 1238452.36 | 450288.65 |  788163.7 |  36.36   | 39950.08 | 8829.19  | 4.5248 |\n",
      "|  类三类买点  |  21  |  18  | 53.85% | 306400.61  |  126543.4 | 179857.22 |   41.3   | 14590.51 | 7030.19  | 2.0754 |\n",
      "| 下跌盘整背驰 |  7   |  13  | 35.0%  | 231731.55  | 109723.72 | 122007.83 |  47.35   | 33104.51 | 8440.29  | 3.9222 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0      |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+------------+-----------+-----------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652365730.5791068.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：2,022,951.82 总手续费：17,672.84\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：102.30% 年化收益率：19.08%\n",
      "最大回撤：-428,593.29 百分比最大回撤：-28.25% 最长回撤天数：64\n",
      "日均收益率：0.05% 收益标准差：1.25% Sharpe Ratio: 0.65 收益回撤比：3.62 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  3   |  1   | 75.0%  |  68819.57 |  11158.56 |  57661.01 |  16.21   | 22939.86 | 11158.56 | 2.0558 |\n",
      "|   二类买点   |  2   |  4   | 33.33% |  78472.87 |  28950.88 |  49521.98 |  36.89   | 39236.43 | 7237.72  | 5.4211 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  35  |  48  | 42.17% | 996052.04 | 405839.12 | 590212.92 |  40.74   | 28458.63 | 8454.98  | 3.3659 |\n",
      "|  类三类买点  |  14  |  14  | 50.0%  | 154699.39 | 107719.11 |  46980.28 |  69.63   | 11049.96 | 7694.22  | 1.4361 |\n",
      "| 下跌盘整背驰 |  4   |  6   | 40.0%  | 349076.61 |  53194.14 | 295882.47 |  15.24   | 87269.15 | 8865.69  | 9.8435 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652367263.9398484.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,927,396.53 总手续费：20,472.15\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：92.74% 年化收益率：17.29%\n",
      "最大回撤：-409,734.12 百分比最大回撤：-21.04% 最长回撤天数：183\n",
      "日均收益率：0.05% 收益标准差：1.10% Sharpe Ratio: 0.69 收益回撤比：4.41 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+---------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 |  平均盈利 | 平均亏损 |  盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+---------+\n",
      "|   一类买点   |  2   |  3   | 40.0%  |  137748.4 |  28418.39 | 109330.01 |  20.63   |  68874.2  |  9472.8  |  7.2707 |\n",
      "|   二类买点   |  3   |  12  | 20.0%  |  96997.08 |  95991.22 |  1005.87  |  98.96   |  32332.36 | 7999.27  |  4.0419 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类买点   |  27  |  45  | 37.5%  | 749243.34 |  543647.4 | 205595.94 |  72.56   |  27749.75 | 12081.05 |  2.297  |\n",
      "|  类三类买点  |  11  |  7   | 61.11% | 130058.51 |  47660.15 |  82398.37 |  36.65   |  11823.5  | 6808.59  |  1.7366 |\n",
      "| 下跌盘整背驰 |  6   |  20  | 23.08% | 784332.83 | 235102.89 | 549229.94 |  29.97   | 130722.14 | 11755.14 | 11.1204 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+---------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652367256.6562152.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,926,154.64 总手续费：25,479.16\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：92.62% 年化收益率：17.27%\n",
      "最大回撤：-488,816.53 百分比最大回撤：-21.40% 最长回撤天数：75\n",
      "日均收益率：0.05% 收益标准差：1.26% Sharpe Ratio: 0.60 收益回撤比：4.33 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+---------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 |  平均盈利 | 平均亏损 |  盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+---------+\n",
      "|   一类买点   |  4   |  3   | 57.14% | 169449.27 |  25866.98 | 143582.29 |  15.27   |  42362.32 | 8622.33  |  4.9131 |\n",
      "|   二类买点   |  3   |  13  | 18.75% |  97997.18 |  95785.82 |  2211.35  |  97.74   |  32665.73 | 7368.14  |  4.4334 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类买点   |  42  |  71  | 37.17% | 1096251.6 | 636841.45 | 459410.14 |  58.09   |  26101.23 |  8969.6  |   2.91  |\n",
      "|  类三类买点  |  11  |  16  | 40.74% |  120614.4 | 109383.81 |  11230.59 |  90.69   |  10964.95 | 6836.49  |  1.6039 |\n",
      "| 下跌盘整背驰 |  2   |  12  | 14.29% | 446021.84 | 111035.53 | 334986.31 |  24.89   | 223010.92 | 9252.96  | 24.1016 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |    0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+---------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652365677.2132375.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,856,986.52 总手续费：20,253.06\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：85.70% 年化收益率：15.98%\n",
      "最大回撤：-354,130.07 百分比最大回撤：-26.92% 最长回撤天数：344\n",
      "日均收益率：0.05% 收益标准差：1.29% Sharpe Ratio: 0.55 收益回撤比：3.18 \n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+-----------+----------+---------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |   亏损   |   净利润  | 回吐比例 |  平均盈利 | 平均亏损 |  盈亏比 |\n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+-----------+----------+---------+\n",
      "|   一类买点   |  2   |  6   | 25.0%  | 127836.91 | 54451.04 |  73385.88 |  42.59   |  63918.46 | 9075.17  |  7.0432 |\n",
      "|   二类买点   |  2   |  11  | 15.38% |  92983.87 | 94036.22 |  -1052.35 |  101.13  |  46491.93 | 8548.75  |  5.4384 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类买点   |  34  |  49  | 40.96% | 813440.12 | 477717.1 | 335723.02 |  58.73   |  23924.71 | 9749.33  |  2.454  |\n",
      "|  类三类买点  |  14  |  11  | 56.0%  | 280931.41 | 95224.44 | 185706.97 |   33.9   |  20066.53 | 8656.77  |  2.318  |\n",
      "| 下跌盘整背驰 |  3   |  6   | 33.33% | 336895.33 | 53656.14 | 283239.18 |  15.93   | 112298.44 | 8942.69  | 12.5576 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |     0     |    0     |    0    |\n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+-----------+----------+---------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652365727.5819082.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,808,356.52 总手续费：17,900.96\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：80.84% 年化收益率：15.07%\n",
      "最大回撤：-384,423.81 百分比最大回撤：-27.35% 最长回撤天数：64\n",
      "日均收益率：0.05% 收益标准差：1.13% Sharpe Ratio: 0.61 收益回撤比：2.96 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  2   |  1   | 66.67% |  56507.25 |   9452.8  |  47054.45 |  16.73   | 28253.63 |  9452.8  | 2.9889 |\n",
      "|   二类买点   |  1   |  3   | 25.0%  |  61618.49 |  22566.86 |  39051.63 |  36.62   | 61618.49 | 7522.29  | 8.1915 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  26  |  46  | 36.11% |  676260.3 | 374083.94 | 302176.36 |  55.32   | 26010.01 | 8132.26  | 3.1984 |\n",
      "|  类三类买点  |  22  |  18  | 55.0%  | 212809.88 | 110628.25 | 102181.64 |  51.98   | 9673.18  | 6146.01  | 1.5739 |\n",
      "| 下跌盘整背驰 |  7   |  15  | 31.82% | 462569.59 | 126995.23 | 335574.35 |  27.45   | 66081.37 | 8466.35  | 7.8052 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652365677.5304065.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,792,962.17 总手续费：19,100.15\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：79.30% 年化收益率：14.79%\n",
      "最大回撤：-365,032.99 百分比最大回撤：-28.09% 最长回撤天数：307\n",
      "日均收益率：0.05% 收益标准差：1.19% Sharpe Ratio: 0.57 收益回撤比：2.82 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  3   |  4   | 42.86% | 121005.74 |  42890.41 |  78115.33 |  35.44   | 40335.25 | 10722.6  | 3.7617 |\n",
      "|   二类买点   |  1   |  9   | 10.0%  |  77597.42 |  71140.34 |  6457.09  |  91.68   | 77597.42 | 7904.48  | 9.8169 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  28  |  50  | 35.9%  | 666318.46 | 489978.63 | 176339.83 |  73.54   | 23797.09 | 9799.57  | 2.4284 |\n",
      "|  类三类买点  |  13  |  11  | 54.17% | 264663.77 |  85819.59 | 178844.18 |  32.43   | 20358.75 | 7801.78  | 2.6095 |\n",
      "| 下跌盘整背驰 |  7   |  12  | 36.84% | 490111.16 | 118009.45 | 372101.71 |  24.08   | 70015.88 | 9834.12  | 7.1197 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652367309.4027648.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,633,735.28 总手续费：20,867.84\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：63.37% 年化收益率：11.82%\n",
      "最大回撤：-298,011.35 百分比最大回撤：-25.57% 最长回撤天数：409\n",
      "日均收益率：0.04% 收益标准差：1.11% Sharpe Ratio: 0.50 收益回撤比：2.48 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 |  平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+--------+\n",
      "|   一类买点   |  3   |  3   | 50.0%  |  30434.08 |  24940.9  |  5493.18  |  81.95   |  10144.69 | 8313.63  | 1.2202 |\n",
      "|   二类买点   |  3   |  7   | 30.0%  | 139560.98 |  56467.05 |  83093.93 |  40.46   |  46520.33 | 8066.72  | 5.7669 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "|   三类买点   |  36  |  58  | 38.3%  |  644500.3 | 416209.37 | 228290.93 |  64.58   |  17902.79 | 7176.02  | 2.4948 |\n",
      "|  类三类买点  |  22  |  21  | 51.16% | 244007.36 | 115467.94 | 128539.43 |  47.32   |  11091.24 | 5498.47  | 2.0171 |\n",
      "| 下跌盘整背驰 |  2   |  11  | 15.38% | 296380.88 |  87385.82 | 208995.06 |  29.48   | 148190.44 | 7944.17  | 18.654 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |     0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+-----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652367326.4546473.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,591,463.64 总手续费：18,091.45\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：59.15% 年化收益率：11.03%\n",
      "最大回撤：-292,445.71 百分比最大回撤：-24.66% 最长回撤天数：409\n",
      "日均收益率：0.04% 收益标准差：1.10% Sharpe Ratio: 0.48 收益回撤比：2.40 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  3   |  3   | 50.0%  |  30633.49 |  26179.46 |  4454.03  |  85.46   | 10211.16 | 8726.49  | 1.1701 |\n",
      "|   二类买点   |  3   |  6   | 33.33% | 141078.79 |  55927.42 |  85151.37 |  39.64   | 47026.26 | 9321.24  | 5.0451 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  26  |  43  | 37.68% | 521767.16 | 320888.15 | 200879.01 |   61.5   | 20067.97 | 7462.52  | 2.6892 |\n",
      "|  类三类买点  |  19  |  19  | 50.0%  |  198875.4 | 101145.42 |  97729.98 |  50.86   | 10467.13 | 5323.44  | 1.9662 |\n",
      "| 下跌盘整背驰 |  5   |  18  | 21.74% | 377741.65 | 156501.52 | 221240.12 |  41.43   | 75548.33 | 8694.53  | 8.6892 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652365701.4251347.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,527,690.39 总手续费：20,453.95\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：52.77% 年化收益率：9.84%\n",
      "最大回撤：-349,186.05 百分比最大回撤：-26.62% 最长回撤天数：344\n",
      "日均收益率：0.03% 收益标准差：1.15% Sharpe Ratio: 0.42 收益回撤比：1.98 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  2   |  6   | 25.0%  | 117857.84 |  51943.24 |  65914.6  |  44.07   | 58928.92 | 8657.21  | 6.8069 |\n",
      "|   二类买点   |  2   |  14  | 12.5%  |  82275.38 |  101783.9 | -19508.52 |  123.71  | 41137.69 | 7270.28  | 5.6583 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  36  |  50  | 41.86% |  717867.0 |  497014.8 |  220852.2 |  69.23   | 19940.75 |  9940.3  | 2.0061 |\n",
      "|  类三类买点  |  13  |  13  | 50.0%  | 283257.65 | 106829.46 | 176428.19 |  37.71   | 21789.05 | 8217.65  | 2.6515 |\n",
      "| 下跌盘整背驰 |  3   |  4   | 42.86% | 130660.36 |  26359.38 | 104300.97 |  20.17   | 43553.45 | 6589.85  | 6.6092 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652365705.2729728.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,505,390.60 总手续费：21,093.69\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：50.54% 年化收益率：9.42%\n",
      "最大回撤：-363,515.64 百分比最大回撤：-26.79% 最长回撤天数：506\n",
      "日均收益率：0.03% 收益标准差：1.07% Sharpe Ratio: 0.43 收益回撤比：1.89 \n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+----------+----------+---------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |   亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 |  盈亏比 |\n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+----------+----------+---------+\n",
      "|   一类买点   |  3   |  6   | 33.33% | 118305.53 | 53168.46 |  65137.07 |  44.94   | 39435.18 | 8861.41  |  4.4502 |\n",
      "|   二类买点   |  1   |  11  | 8.33%  |  72950.76 | 78306.13 |  -5355.37 |  107.34  | 72950.76 | 7118.74  | 10.2477 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   三类买点   |  29  |  56  | 34.12% | 554078.49 | 540198.3 |  13880.19 |  97.49   | 19106.15 |  9646.4  |  1.9807 |\n",
      "|  类三类买点  |  17  |  11  | 60.71% | 403457.08 | 94631.44 | 308825.64 |  23.46   | 23732.77 | 8602.86  |  2.7587 |\n",
      "| 下跌盘整背驰 |  7   |  11  | 38.89% | 242880.89 | 99153.31 | 143727.58 |  40.82   | 34697.27 | 9013.94  |  3.8493 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+----------+----------+---------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652367236.2419941.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,489,731.12 总手续费：19,566.25\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：48.97% 年化收益率：9.13%\n",
      "最大回撤：-260,405.63 百分比最大回撤：-21.59% 最长回撤天数：324\n",
      "日均收益率：0.03% 收益标准差：1.00% Sharpe Ratio: 0.45 收益回撤比：2.27 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  3   |  3   | 50.0%  | 160751.02 |  26715.0  | 134036.02 |  16.62   | 53583.67 |  8905.0  | 6.0173 |\n",
      "|   二类买点   |  5   |  13  | 27.78% | 202883.48 |  99476.61 | 103406.86 |  49.03   | 40576.7  | 7652.05  | 5.3027 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  29  |  54  | 34.94% | 695632.64 | 541857.95 | 153774.69 |  77.89   | 23987.33 | 10034.41 | 2.3905 |\n",
      "|  类三类买点  |  11  |  8   | 57.89% | 166190.44 |  64515.86 | 101674.58 |  38.82   | 15108.22 | 8064.48  | 1.8734 |\n",
      "| 下跌盘整背驰 |  2   |  12  | 14.29% | 117137.09 | 101105.05 |  16032.04 |  86.31   | 58568.55 | 8425.42  | 6.9514 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}\n",
      "落地文件：./data/bk/_optimization_1652367289.541162.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,345,884.20 总手续费：15,231.95\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：34.59% 年化收益率：6.45%\n",
      "最大回撤：-360,886.15 百分比最大回撤：-23.94% 最长回撤天数：386\n",
      "日均收益率：0.02% 收益标准差：0.95% Sharpe Ratio: 0.34 收益回撤比：1.44 \n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+----------+----------+---------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |   亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 |  盈亏比 |\n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+----------+----------+---------+\n",
      "|   一类买点   |  3   |  3   | 50.0%  |  21173.1  | 25619.16 |  -4446.07 |  121.0   |  7057.7  | 8539.72  |  0.8265 |\n",
      "|   二类买点   |  3   |  7   | 30.0%  | 293659.63 | 54962.06 | 238697.57 |  18.72   | 97886.54 | 7851.72  | 12.4669 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   三类买点   |  21  |  45  | 31.82% | 386903.41 | 381010.7 |  5892.71  |  98.48   | 18423.97 |  8466.9  |  2.176  |\n",
      "|  类三类买点  |  16  |  14  | 53.33% | 280515.52 | 87091.7  | 193423.81 |  31.05   | 17532.22 | 6220.84  |  2.8183 |\n",
      "| 下跌盘整背驰 |  1   |  12  | 7.69%  |  12650.87 | 85566.44 | -72915.57 |  676.37  | 12650.87 | 7130.54  |  1.7742 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |    0     |     0     |    0     |    0     |    0     |    0    |\n",
      "+--------------+------+------+--------+-----------+----------+-----------+----------+----------+----------+---------+\n",
      "* * * * * * * * * * * * * * * * * * * * \n",
      "参数：{'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}\n",
      "落地文件：./data/bk/_optimization_1652367310.1365035.pkl\n",
      "首个交易日：2017-01-03 00:00:00 最后交易日：2022-04-20 00:00:00 总交易日：1287\n",
      "起始资金：1000000 结束资金：1,147,929.25 总手续费：15,093.72\n",
      "基准收益率：1.47%  基准年化收益：0.27%%\n",
      "总收益率：14.79% 年化收益率：2.76%\n",
      "最大回撤：-287,809.98 百分比最大回撤：-24.74% 最长回撤天数：926\n",
      "日均收益率：0.01% 收益标准差：0.86% Sharpe Ratio: 0.16 收益回撤比：0.60 \n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|    买卖点    | 成功 | 失败 |  胜率  |    盈利   |    亏损   |   净利润  | 回吐比例 | 平均盈利 | 平均亏损 | 盈亏比 |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "|   一类买点   |  3   |  3   | 50.0%  |  21859.56 |  26810.29 |  -4950.73 |  122.65  | 7286.52  | 8936.76  | 0.8153 |\n",
      "|   二类买点   |  2   |  5   | 28.57% |  57189.61 |  46740.57 |  10449.04 |  81.73   | 28594.8  | 9348.11  | 3.0589 |\n",
      "|  类二类买点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类买点   |  20  |  35  | 36.36% | 371472.37 | 322199.21 |  49273.16 |  86.74   | 18573.62 | 9205.69  | 2.0176 |\n",
      "|  类三类买点  |  14  |  14  | 50.0%  | 232137.36 |  83131.4  | 149005.95 |  35.81   | 16581.24 | 5937.96  | 2.7924 |\n",
      "| 下跌盘整背驰 |  5   |  21  | 19.23% | 128645.89 | 169609.18 | -40963.29 |  131.84  | 25729.18 | 8076.63  | 3.1856 |\n",
      "| 下跌趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   一类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   二类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类二类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|   三类卖点   |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "|  类三类卖点  |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨盘整背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "| 上涨趋势背驰 |  0   |  0   |   0%   |     0     |     0     |     0     |    0     |    0     |    0     |   0    |\n",
      "+--------------+------+------+--------+-----------+-----------+-----------+----------+----------+----------+--------+\n",
      "[{'end_balance': 2437265.1331046238, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652365769.0102267.pkl'}, {'end_balance': 2229519.9487763536, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652367274.7952995.pkl'}, {'end_balance': 2163443.5413421304, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652365754.5777833.pkl'}, {'end_balance': 2022585.8208644963, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652365730.5791068.pkl'}, {'end_balance': 1927087.9665521877, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652367263.9398484.pkl'}, {'end_balance': 1925941.535392772, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652367256.6562152.pkl'}, {'end_balance': 1856749.634900653, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652365677.2132375.pkl'}, {'end_balance': 1808137.4779591504, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652365727.5819082.pkl'}, {'end_balance': 1792757.9881232777, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652365677.5304065.pkl'}, {'end_balance': 1633544.6879542556, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652367309.4027648.pkl'}, {'end_balance': 1591363.0648138248, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_no', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652367326.4546473.pkl'}, {'end_balance': 1527533.4967299753, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652365701.4251347.pkl'}, {'end_balance': 1505121.4108310766, 'params': {'bi_type': 'bi_type_old', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652365705.2729728.pkl'}, {'end_balance': 1489357.9429361462, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_bz', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652367236.2419941.pkl'}, {'end_balance': 1345420.5082756025, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_bz'}, 'save_file': './data/bk/_optimization_1652367289.541162.pkl'}, {'end_balance': 1147720.4051074537, 'params': {'bi_type': 'bi_type_new', 'bi_bzh': 'bi_bzh_yes', 'zs_bi_type': 'zs_type_dn', 'zs_xd_type': 'zs_type_dn'}, 'save_file': './data/bk/_optimization_1652367310.1365035.pkl'}]\n"
     ]
    }
   ],
   "source": [
    "# 跑参数优化\n",
    "results = BT.run_optimization(setting)\n",
    "print(results)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
